package com.bifrost.util;

/**
 * Created by admin on 2018/5/3.(YYR) 生成采购单CODE工具类
 */
public class PurchaseOrderCodeUtils {


    public static String addZeroForNum(String str, int strLength) {
        int strLen = str.length();
        StringBuffer sb = null;
        while (strLen < strLength) {
            sb = new StringBuffer();
            sb.append("0").append(str);// 左补0
            str = sb.toString();
            strLen = str.length();
        }
        return "10"+str;
    }


    /**
     * 生成劵码
     * @param str
     * @param strLength
     * @return
     */
    public static String addCouponCode(String str, int strLength,Boolean developmentFlag) {
        int strLen = str.length();
        StringBuffer sb = null;
        while (strLen < strLength) {
            sb = new StringBuffer();
            sb.append("0").append(str);// 左补0
            str = sb.toString();
            strLen = str.length();
        }
        //生成4位随机数
        int rom=(int)((Math.random()*9+1)*1000);
        return "85"+str+rom;
    }
}
